package com.black.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.black.common.constant.UserConstants;
import com.black.common.core.domain.entity.SysUser;
import com.black.system.domain.req.system.query.SysUserQueryReq;
import com.black.system.domain.resp.system.SysUserResp;
import com.black.system.service.SysUserService;
import com.black.system.mapper.SysUserMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

/**
 * @author L
 * @description 针对表【sys_user(用户信息表)】的数据库操作Service实现
 * @createDate 2024-08-19 10:07:23
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
        implements SysUserService {

    @Override
    public boolean checkDeptExistUser(Long deptId) {
        LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
        query.eq(SysUser::getDeptId, deptId);
        query.eq(SysUser::getDelFlag, UserConstants.NORMAL);
        return this.baseMapper.selectCount(query) > 0;
    }

    /**
     * 分页查询用户信息
     * @param req
     * @return
     */
    @Override
    public PageInfo<SysUserResp> paginationQuery(SysUserQueryReq req) {
        return PageHelper.startPage(req.getPageNum(), req.getPageSize()).doSelectPageInfo(() -> {
            this.baseMapper.paginationQuery(req);
        });
    }
}




